package com.ycfmedical.bed.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.bilibili.magicasakura.widgets.TintTextView;
import com.ycfmedical.bed.HisConstants;
import com.ycfmedical.bed.R;
import com.ycfmedical.bed.local.entity.HisSystemInfo;

import butterknife.BindView;
import cn.droidlover.xdroidmvp.base.SimpleRecAdapter;
import cn.droidlover.xdroidmvp.kit.KnifeKit;

/**
 * Created by Administrator on 2017/3/16 0016. 历史账单记录Adapter
 */

public class HisBillInfoAdapter extends SimpleRecAdapter<HisSystemInfo, HisBillInfoAdapter.ViewHolder>
{
    public static final int TAG_VIEW = 0;

    public HisBillInfoAdapter(Context context)
    {
        super(context);
    }

    @Override
    public HisBillInfoAdapter.ViewHolder newViewHolder(View itemView)
    {
        return new ViewHolder(itemView);
    }

    @Override
    public int getLayoutId()
    {
        return R.layout.adapter_bill;
    }

    @Override
    public void onBindViewHolder(HisBillInfoAdapter.ViewHolder holder, int position)
    {
        final HisSystemInfo item = data.get(position);
        // 主题
        holder.tvTitle.setText(HisConstants.HOSPITAL_NAME);
        holder.tvCount.setText(HisConstants.HEALTH_INSURANCE + item.getHealthinsurance());
        holder.tvKeyword.setText(HisConstants.HOSPITAL_APTITUDE);
        // 项目
        holder.billItem.setText(HisConstants.BILL_ITEM);
        holder.billItem1.setText(HisConstants.HOSPITAL);
        holder.billItem2.setText(HisConstants.INSPECTION);
        holder.billItem3.setText(HisConstants.NURSE);
        holder.billItem4.setText(HisConstants.CURE);
        holder.billItem5.setText(HisConstants.MEDICINE);
        // 金额
        holder.cost.setText(HisConstants.BILL_ITEM);
        holder.costItem1.setText("" + item.getHospital());
        holder.costItem2.setText("" + item.getInspection());
        holder.costItem3.setText("" + item.getNurse());
        holder.costItem4.setText("" + item.getCure());
        holder.costItem5.setText("" + item.getMedicine());
        // 计算后的金额
        holder.pay.setText(HisConstants.REIMBURSEMENT_AMOUNT);
        holder.payItem1.setText("" + item.getHospital() * item.getHealthinsurance());
        holder.payItem2.setText("" + item.getInspection() * item.getHealthinsurance());
        holder.payItem3.setText("" + item.getNurse() * item.getHealthinsurance());
        holder.payItem4.setText("" + item.getCure() * item.getHealthinsurance());
        holder.payItem5.setText("" + item.getMedicine() * item.getHealthinsurance());
        // ILFactory.getLoader().loadNet(holder.ivCover, item.getImg(), null);

        holder.itemView.setOnClickListener(new View.OnClickListener()
        {
            @Override
            public void onClick(View v)
            {
                if (getRecItemClick() != null)
                {
                    getRecItemClick().onItemClick(position, item, TAG_VIEW, holder);
                }
            }
        });
    }

    public static class ViewHolder extends RecyclerView.ViewHolder
    {

        @BindView(R.id.tv_title)
        TintTextView tvTitle;
        @BindView(R.id.tv_count)
        TintTextView tvCount;
        @BindView(R.id.tv_keyword)
        TintTextView tvKeyword;
        @BindView(R.id.bill_item)
        TintTextView billItem;
        @BindView(R.id.bill_item1)
        TintTextView billItem1;
        @BindView(R.id.bill_item2)
        TintTextView billItem2;
        @BindView(R.id.bill_item3)
        TintTextView billItem3;
        @BindView(R.id.bill_item4)
        TintTextView billItem4;
        @BindView(R.id.bill_item5)
        TintTextView billItem5;
        @BindView(R.id.bill_item6)
        TintTextView billItem6;
        @BindView(R.id.cost)
        TintTextView cost;
        @BindView(R.id.cost_item1)
        TintTextView costItem1;
        @BindView(R.id.cost_item2)
        TintTextView costItem2;
        @BindView(R.id.cost_item3)
        TintTextView costItem3;
        @BindView(R.id.cost_item4)
        TintTextView costItem4;
        @BindView(R.id.cost_item5)
        TintTextView costItem5;
        @BindView(R.id.cost_item6)
        TintTextView costItem6;
        @BindView(R.id.pay)
        TintTextView pay;
        @BindView(R.id.pay_item1)
        TintTextView payItem1;
        @BindView(R.id.pay_item2)
        TintTextView payItem2;
        @BindView(R.id.pay_item3)
        TintTextView payItem3;
        @BindView(R.id.pay_item4)
        TintTextView payItem4;
        @BindView(R.id.pay_item5)
        TintTextView payItem5;
        @BindView(R.id.pay_item6)
        TintTextView payItem6;

        public ViewHolder(View itemView)
        {
            super(itemView);
            KnifeKit.bind(this, itemView);
        }
    }
}
